package com.smforj.ssm.sys.web.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smforj.ssm.sys.common.AjaxResult;
import com.smforj.ssm.sys.model.vo.UserInfoVO;
import com.smforj.ssm.sys.service.IUserInfoService;

/**
 * Description: LoginController
 * Author: shibiao
 * Create: 2016-10-01
 */
@Controller
public class LoginController {

    @Resource
    private IUserInfoService userInfoService;

    @RequestMapping("/login")
     @ResponseBody
     public AjaxResult login(@RequestBody UserInfoVO userInfoVO) {
        AjaxResult ajaxResult = new AjaxResult();
        boolean result = userInfoService.isLogin(userInfoVO.getUserName(),userInfoVO.getPassword());
        ajaxResult.setSuccess(result);
        ajaxResult.setMessage(result?"成功":"失败");
        return ajaxResult;
    }
    @RequestMapping("/toLogin")
    public String tologin() {
        return "/login/login";
    }
}
